<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>迭代器</title>
	</head>
	<body>
		<script>
			const arr = ['qq','baidu','taobao'];
			
			for(let n of arr) {
				console.log(n);
			}
			console.log(arr);
			let iterator = arr[Symbol.iterator]();
			console.log(iterator.next());
			const bj = {
				name: 'zhongjiyiban',
				status: ['one','two','three','four','five'],
				age:100,
				[Symbol.iterator]() {
					// 索引变量
					let idx = 0;
					let _this = this;
					return {
						next:function() {
							if(idx < _this.status.length) {
								const resut = {value:_this.status[idx],done:false};
								idx++;
								return resut;
							} else{
								return {value:undefined,done: true};
							}
						}
					};
				}
			};
			for(let v of bj) {
				console.log(v);	
			}
		</script>
	</body>
</html>